using Game.Const;
using Game.Core;
using Game.Main.Model;
using Game.Main.View;
using Game.Manager;
using UnityEngine;

namespace Game.Component
{
	public class ItemCreatorItem : BaseItem
	{
		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override void QuicklyTouch(TouchEventData touchEventData)
		{
			base.QuicklyTouch(touchEventData);
			if (base.itemData.createIds != null && archiveData.createIndexs.Count < base.itemData.createAmount)
			{
				Transform transform = model.Find("CreatePoint");
				BaseItem baseItem = Singleton<Scene>.Instance.CreateItem(base.itemData.createIds[Random.Range(0, base.itemData.createIds.Length)], transform.position, 0);
				if (baseItem != null)
				{
					AddCreateItem(baseItem);
					baseItem.DropDown(transform.position, true);
				}
				Singleton<AudioManager>.Instance.PlaySound("sound_btn_1");
				if (base.itemData.scriptParams.Equals("1"))
				{
					Singleton<AudioManager>.Instance.PlaySound("sound_explode");
					Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + "efc_explode_1", baseItem.transform.position + new Vector3(0f, 0.2f, -0.0004f), 1f);
					Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + "efc_blink_1", baseItem.transform.position + new Vector3(0f, -0.6f, -0.0004f), 3f);
				}
			}
			else
			{
				Singleton<AudioManager>.Instance.PlaySound("sound_atm_error");
			}
		}
	}
}
